Beginning SAP Fiori by Bince Mathew

Beginning SAP Fiori by Bince Mathew

Author:Bince Mathew
Language: eng
Format: epub, pdf
Publisher: Apress, Berkeley, CA


Next you create the controller page for your Users view, to handle events like button clicks, page loads, and so on (see Listing 5-8). The selectedRow function gets the details of any row the user clicks in the table. Similarly, you use JQuery functions to read values directly from fields and toggle the visibility of the form that contains the input fields for creating and editing records based on button clicks.

Listing 5-8. Users.controller.js (Controller Page to Handle the Events of the View)

selectedRow: function(oEvent){

currentRowContext = oEvent.getParameter("rowContext").sPath;

var start = currentRowContext.lastIndexOf('/') + 1;

value = currentRowContext.substring(start, currentRowContext.length);

var oTable = sap.ui.getCore().byId('Table1');

index = oTable.getSelectedIndex();

var data= oTable.getModel().oData[value];

mode = "Update";

$('#Userid').val(data.Userid);

$('#Name').val(data.Name);

$('#Designation').val(data.Designation);

var userId = sap.ui.getCore().byId('Userid');

userId.setEditable(false);

},

Create: function(){

$('#form1').slideDown();

mode = "Create";

$('#Userid').val("");

$('#Name').val("");

$('#Designation').val("");

var userId = sap.ui.getCore().byId('Userid');

userId.setEditable(true);

},

Edit: function(){

$('#form1').slideDown('1000');

mode = "Update";

var oTable = sap.ui.getCore().byId('Table1');

index = oTable.getSelectedIndex();

var data= oTable.getModel().oData[value];

$('#Userid').val(data.Userid);

$('#Userid').editable = false;

$('#Name').val(data.Name);

$('#Designation').val(data.Designation);

},



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.